<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Repositories\NewsRepo;

class NewsController extends BaseController
{
    //
     //
    public function index(Request $request)
    {
         $newsRepo = new NewsRepo();
         $data = $newsRepo->getNewsList();
         return $this->sucRes(200,$data);
    }
    public function create(Request $request)
    {
        $data = $request->only(['title','sub_title','description','content','image','status']);
        $newsRepo = new NewsRepo();
        $newsRepo->create($data);
        return $this->sucRes();

    }
    public function update(Request $request)
    {
        $data = $request->only(['title','sub_title','description','content','status','image']);
        $id = $request->id;
        $newsRepo = new NewsRepo();
        $newsRepo->update($id,$data);
        return $this->sucRes();
    }
    public function del(Request $request)
    {
         $id = $request->id;
         $newsRepo = new NewsRepo();
         $newsRepo->del($id);
         return $this->sucRes();
    }
    public function info(Request $request)
    {
        $id = $request->id;
        $newsRepo = new NewsRepo();
        $data = $newsRepo->getOneById($id);
        return $this->sucRes(200,$data);
    }
}
